const SlotTree = (hook, { Tree }) => {
	return {
		isJiess: true,
		name: 'SlotTree',
		setup({ midder, create, onSelect, onExpand, ...args }) {
			const { $reactive } = hook.$m;
			const data = (midder.tree = $reactive({
				expandedKeys: [],
				selectedKeys: [],
				treeData: [],
			}));
			// =====================用于异步提供数据=====================
			if (typeof create === 'function') create.call(this, data);
			this.add({ $slot: 'header' }, {
				is: Tree,
				treeData: { $proxy: data, field: 'treeData' },
				expandedKeys: { $proxy: data, field: 'expandedKeys' },
				selectedKeys: { $proxy: data, field: 'selectedKeys' },
				onExpand(keys, ...arg) {
					data.expandedKeys = keys;
					if (typeof onExpand === 'function') onExpand(keys, ...arg);
				},
				onSelect(keys, ...arg) {
					data.selectedKeys = keys;
					if (typeof onSelect === 'function') onSelect(keys, ...arg);
				},
				...args,
			});
		},
	};
}
export default SlotTree